<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version='1.0' >
    <xsl:template match="foods">
        <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
             <fo:layout-master-set>
                <fo:simple-page-master master-name="content"
                page-height="8.5in" page-width="11in"
                 margin-top="0.5in" margin-bottom="0.5in"
                 margin-left="1in" margin-right="1in">
                    <fo:region-body/>
                </fo:simple-page-master>
            </fo:layout-master-set>
            <fo:page-sequence master-reference="content">
                <fo:flow flow-name="xsl-region-body">                
                    
                    <fo:table border-collapse="separate" table-layout="fixed">
                        <fo:table-column column-width="6cm"/>
                        <fo:table-column column-width="3cm"/>
                        <fo:table-column column-width="3cm"/>
                        <fo:table-column column-width="3cm"/>
                        <fo:table-column column-width="3cm"/>
                        <fo:table-column column-width="6cm"/>
                        <fo:table-body>
                            <fo:table-row>                                
                                <fo:table-cell column-number="1" border-color="black" border-width="0.5pt" border-style="solid">
                                    <fo:block text-align="center">Food Name</fo:block>
                                </fo:table-cell>
                                <fo:table-cell column-number="2" border-color="black" border-width="0.5pt" border-style="solid">
                                    <fo:block text-align="center">Calories</fo:block>
                                </fo:table-cell>
                                <fo:table-cell column-number="3" border-color="black" border-width="0.5pt" border-style="solid">
                                    <fo:block text-align="center">Carb</fo:block>
                                </fo:table-cell>
                                <fo:table-cell column-number="4" border-color="black" border-width="0.5pt" border-style="solid">
                                    <fo:block text-align="center">Protein</fo:block>
                                </fo:table-cell>
                                <fo:table-cell column-number="5" border-color="black" border-width="0.5pt" border-style="solid">
                                    <fo:block text-align="center">Fat</fo:block>
                                </fo:table-cell>
                                <fo:table-cell column-number="6" border-color="black" border-width="0.5pt" border-style="solid">
                                    <fo:block text-align="center">Image</fo:block>
                                </fo:table-cell>
                            </fo:table-row>
                            <xsl:for-each select="food">
                                <fo:table-row>
                                    <fo:table-cell column-number="1" border-color="black" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center">
                                            <xsl:value-of select="foodName" />
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell column-number="2" border-color="black" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center">
                                            <xsl:value-of select="calorie" />
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell column-number="3" border-color="black" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center">
                                            <xsl:value-of select="carb" />
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell column-number="4" border-color="black" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center">
                                            <xsl:value-of select="protein" />
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell column-number="5" border-color="black" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center">
                                            <xsl:value-of select="fat" />
                                        </fo:block>
                                    </fo:table-cell>
                                    <fo:table-cell column-number="6" border-color="black" border-width="0.5pt" border-style="solid">
                                        <fo:block text-align="center">
                                            <xsl:variable name="image" select="imageURL"/>
                                            <fo:external-graphic src="url('images/food/{$image}')"
                                                                content-height="scale-to-fit" height="2.00in"
                                                                content-width="2.00in"
                                                                scaling="non-uniform"/>
                                        </fo:block>
                                    </fo:table-cell>
                                </fo:table-row>
                            </xsl:for-each>
                        </fo:table-body>
                    </fo:table>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>

    </xsl:template>

</xsl:stylesheet>